<template>
  <div>
    <TaskCard
      v-on:reload="getTaskList"
      v-for="(item,index) in taskList"
      :key="index"
      :taskInfo="item"
    ></TaskCard>
    <el-col :span="5" :offset="2" style="margin-bottom:35px">
      <el-card
        class="new"
        v-if="this.$store.state.user.type == '2'"
        @click.native="add"
        :body-style="{ padding: '15px' }"
      >
        <i class="el-icon-plus avatar-uploader-icon"></i>
        <p class="new-text">添加新的作业</p>
      </el-card>
    </el-col>
  </div>
</template>

<script>
import { post, getList } from "@/api/task";
import TaskCard from "./TaskCard";
export default {
  name: "",
  data() {
    return {
      cno: this.$parent.cno,
      taskList: []
    };
  },
  mounted() {
    this.getTaskList();
  },
  methods: {
    async getTaskList() {
      const { data: res } = await getList(this.cno);
      this.taskList = res.data.data;
    },
    add() {
      this.$router.push({
        path: "task_input"
      });
    }
  },
  components: {
    TaskCard
  }
};
</script>

<style scoped>
.add_btn {
  float: left;
}
.new {
  cursor: pointer;
  border-radius: 6px;
  position: relative;
  background: url("https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3995543628,1724060080&fm=26&gp=0.jpg")
    center no-repeat/cover;
  bottom: 17px;
  right: 115px;
  width: 360px;
  height: 260px;
  box-sizing: border-box;
}
.new:hover .el-icon-plus {
  font-size: 100px;
  transition: font-size 0.4s;
}
.new:hover .new-text {
  top: -30px;
  transition: top 0.4s;
}
.el-icon-plus {
  color: #9e2020;
  font-size: 50px;
}
.new-text {
  font-size: 20px;
  color: #9e2020;
  position: relative;
  top: 200px;
  font-weight: 900;
}
</style>